package com.efg.games.superclick.my
{
    import adobe.utils.CustomActions;
    import flash.display.Graphics;
    import flash.display.LineScaleMode;
    import flash.display.Sprite;
    
    /**
     * ...
     * @author jianping.shenjp
     */
    public class Circle extends Sprite implements IDispose,IUpdate
    {
        
        private const reduceAlpha:Number = 0.05;
        private var _color:uint = 0;
        private var _radius:Number = 0;
        private var _circleGrowSpeed:Number = 0;
        private var _fadingOut:Boolean = false;
        
        public function Circle(color:uint, radius:Number, circleGrowSpeed:Number)
        {
            buttonMode = true;
            useHandCursor = true;
            _color = color;
            _radius = radius;
            _circleGrowSpeed = circleGrowSpeed;
            draw();
        }
        
        private function draw():void
        {
            var g:Graphics = this.graphics;
            g.clear();
            g.lineStyle(2, 0xFFFFFF, 1, false, LineScaleMode.NONE);
            g.beginFill(_color);
            g.drawCircle(0, 0, _radius);
            g.endFill();
            this.scaleX = 0.5;
            this.scaleY = 0.5;
        }
        
        public function update():void
        {
            if (!_fadingOut)
            {
                this.scaleX += _circleGrowSpeed;
                this.scaleY += _circleGrowSpeed;
            }
            else
            {
                this.alpha -= reduceAlpha;
            }
        }
        
        public function isDispose():Boolean
        {
            if (this.alpha <= 0)
            {
                return true;
            }
            return false;
        }
        
        public function dispose():void
        {
            var g:Graphics = this.graphics;
            g.clear();
            g = null;
        }
        
        public function get color():uint
        {
            return _color;
        }
        
        public function get fadingOut():Boolean
        {
            return _fadingOut;
        }
        
        public function set fadingOut(value:Boolean):void
        {
            _fadingOut = value;
        }
    }

}